#ifndef PSKILLDIALOG_H
#define PSKILLDIALOG_H
#include <QGraphicsObject>
#include <QEventLoop>
#include "foregroundscene.h"
#include "gameanimation.h"
#include "player.h"

class SkillBackground : public QGraphicsObject
{
public:
    SkillBackground(QGraphicsObject* parent = 0);
    QRectF boundingRect() const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);

};

class SkillTextInfo : public QGraphicsObject
{
public:
    SkillTextInfo(QGraphicsObject* parent = 0, QString content = 0);
    QRectF boundingRect() const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
    QString _content;
    static const int SKILL_TEXT_WIDTH = 400;
};

class SkillOwner : public QGraphicsObject
{
public:
    SkillOwner(QGraphicsObject* parent = 0);
    QRectF boundingRect() const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);

    static const int SKILL_OWNER_WIDTH = 80;
    static const int SKILL_OWNER_HEIGHT = 80;
};

class SkillOwnerBig : public QGraphicsObject
{
public:
    SkillOwnerBig(QGraphicsObject* parent, const QPixmap &pix);
    QRectF boundingRect() const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
protected:
    QPixmap _pix;
};

class pskilldialog : public QGraphicsObject
{
    Q_OBJECT
public:
    pskilldialog(QGraphicsObject* parent = 0);
    QRectF boundingRect() const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
    void enter();

    static const int SKILL_WIDTH = 500;
    static const int SKILL_HEIGHT = 500;

    player* _Player;
protected:
    SkillBackground* back;
    SkillOwner* owner;
    SkillOwnerBig* ownerBig;
    SkillTextInfo* text;
    InputBlocker* diaBlock;

    GameSeqAnimation* enterAnim;

    void prepare();
    void createAnimation();
    virtual void useSkill() = 0;

signals:

public slots:
    void skill();
    void leave();
    void finished();


};

class PlayerTao : public QGraphicsObject
{
    Q_OBJECT
public:
    PlayerTao(QGraphicsObject* parent, const QPixmap &pix);
    QRectF boundingRect() const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
    int width() {return _taoPix.width();}
    int height() {return _taoPix.height();}

    int _width; int _height;

protected:
    QPixmap _taoPix;
    void mousePressEvent(QGraphicsSceneMouseEvent *event);
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
signals:
    void pressed();

};

class YellowSkill : public pskilldialog
{
    Q_OBJECT
public:
    YellowSkill(QGraphicsObject* parent, player* pl, const QPixmap &pix);
    PlayerTao* redTao;
    PlayerTao* yellowTao;
    PlayerTao* blueTao;
    PlayerTao* greenTao;
    PlayerTao* blackTao;
protected:
    void useSkill();
    void TaoAnimation();
    void leaveTao();
private slots:
    void addRedTao();
    void addYellowTao();
    void addBlueTao();
    void addGreenTao();
    void addBlackTao();
    void connectTao();
};




#endif // PSKILLDIALOG_H
